<template>
	<view >
		<mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption" :top="230">
			<view v-for="(item,index) in list" :key="index">
				<ItemCus :item="item" @rouTo="toDetails" @dealOrder="dealOrder"/>
			</view>			
		</mescroll-uni>
	</view>
</template>

<script>
	import {getFormList , customerRemind, acceptance} from '../../../api/message.js';
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import ItemCus from './listItemCus.vue'
	export default {
		name:"customer",
		mixins: [MescrollMixin], // 使用mixin
		components:{
			ItemCus
		},
		data() {
			return {
				list:[],
				page:{
					pageIndex:1,
					pageSize:10
				},
				pages:0,
				upOption:{
					auto:false
				}
			};
		},
		methods:{
			toDetails(v){

				const params ={
					orderId:v.orderId
				}
				this.$navTo.togo('/pages/views/clientreview/returnvisit',params)				
			},
			dealOrder(v){
				let params = {
					orderCode :v.orderCode
				}
				acceptance(params).then(res=>{
					if(res.result === '1'){
						uni.showToast({
							title:'受理成功',
							icon:"none",
							duration:2000
						})
						this.downCallback()
					} else {
						uni.showToast({
							title:res.msg,
							icon:"none",
							duration:2000
						})
					}
				})
			},
			downCallback(){
				this.list = []
				this.mescroll.resetUpScroll( true )	
			},
			async upCallback(page){
				console.log(page)
				let params = {
					pageIndex:page.num,
					pageSize:page.size
				}
				if(page.num === 1) this.list = []
				let res = await customerRemind(params)
				if(res.result === '1'){
					this.mescroll.endSuccess(res.rows.length)
					this.list = [...this.list,...res.rows]
				} else {
					this.mescroll.endErr()
				}
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
